package pack.utilitaires;

import java.util.Calendar;

public class DateConverter {
	public static Calendar stringToDate(String date){
		String date1[] = date.trim().split("-");
		Calendar maDate = Calendar.getInstance();
		maDate.set(Integer.parseInt(date1[0]),
				   Integer.parseInt(date1[1])-1,
				   Integer.parseInt(date1[2]));
		return maDate;
	}
	public static String dateToString(Calendar maDate){
		String date;
		String mois = ((maDate.get(Calendar.MONTH)<9)?"0":"")+(maDate.get(Calendar.MONTH)+1);
		String jour = ((maDate.get(Calendar.DAY_OF_MONTH)<10)?"0":"")+maDate.get(Calendar.DAY_OF_MONTH);
		date=maDate.get(Calendar.YEAR)+"-"+mois+"-"+jour;
		return date;
	}
}
